<!-- HTML5文件 -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
		<title>绑卡页</title>
		<link rel="stylesheet" href="assets/agile/css/agile.layout.css">
		<link rel="stylesheet" href="assets/agile/css/flat/flat.component.css">
		<link rel="stylesheet" href="assets/agile/css/flat/flat.color.css">
		<link rel="stylesheet" href="assets/agile/css/flat/iconline.css">
		<link rel="stylesheet" href="assets/agile/css/flat/iconform.css">
		<link rel="stylesheet" href="assets/component/timepicker/timepicker.css">
		<link rel="stylesheet" href="assets/app/css/app.css">
		<link rel="stylesheet" href="assets/my/common/style.css" />
	</head>
	<body>
		<div id="section_container">
			<section id="form_section" data-role="section" class="active">
				<header>
					<div class="titlebar">
						<a data-toggle="back" href="#"><i class="iconfont iconline-arrow-left"></i></a>
						<h1 class="title">绑定交易卡</h1>
					</div>

				</header>

				<article data-role="article" id="main_article" data-scroll="verticle" class="active" style="top:44px;bottom:50px;">
					<div class="scroller">
						<form class="form-common" action="http://182.92.241.133:8001/API/FrontBackInf/LoginVerify?userName=18638102151&Pwd=123456&marketNo=kfhj&softType=1">
							<br/>
							<br/>
							<br/>
							
							<label class="label-left" for="user">农批市场:</label>
							<label class="label-right">
								<select placeholder="选择市场" id="market">
									<option value="0">选择市场</option>
									<script id="template" type="text/html">
									<% for (i = 0; i < ObjectList.length; i ++) { %>
								  	<option value="<%= ObjectList[i].MarketID %>"><%= ObjectList[i].MarketName %></option>
								  	<% } %>
                                    </script>
								</select>
							</label>
							
							<br/>
							<br/>
							<br/>
							<label class="label-left" for="user">交易卡号:</label>
							<label class="label-right">
								<input id="card" type="text" placeholder="市场卡号" value="51263"/>
							</label>
							<hr/>
							<label class="label-left" for="email">卡密码:</label>
							<label class="label-right">
								<input id="pwd" type="password" placeholder="卡密码" value="111111"/>
							</label>
							<hr/>
							<br/>
							<br/>
							<br/>
							<button class="block submit" href="#list" data-toggle="html" class="navigate-right" id="bdbtn">
								绑定
							</button>
							<br/>
						</form>
					</div>
				</article>
			</section>
		</div>

		<!--- third --->
		<script src="assets/third/jquery/jquery-2.1.3.min.js"></script>
		<script src="assets/third/jquery/jquery.mobile.custom.min.js"></script>
		<script src="assets/third/iscroll/iscroll-probe.js"></script>
		<script src="assets/third/arttemplate/template-native.js"></script>
		<!-- agile -->
		<script type="text/javascript" src="assets/agile/js/agile.js"></script>
		<!--- bridge --->
		<script type="text/javascript" src="assets/bridge/exmobi.js"></script>
		<script type="text/javascript" src="assets/bridge/agile.exmobi.js"></script>
		<!-- app -->
		<script src="assets/component/timepicker/agile.timepicker.js"></script>
		<script type="text/javascript" src="assets/component/extend.js"></script>
		<script type="text/javascript" src="assets/app/js/app.js"></script>
		<!-- my -->
		<script type="text/javascript" src="assets/my/common/my.js"></script>
		<script type="text/javascript" src="assets/my/common/jquery.md5.js"></script>
		<script>
		$('#main_article').on('articleload', function(){//监听主页面打开事件,判断是否有COOKIE,并进行自动登录.
			if(getCookie("UserID")>0){
				var _url=encodeURIComponent("http://182.92.241.133:8001/API/FrontBackInf/GetMarketList");
				myAjax(_url,changePage);//进行跨域请求json
			}else{
				A.alert('错误','请先进行登陆操作',function(){
				    A.Controller.html("login.html"); 
				});
			}
		});

		function changePage(json){//供跨域请求获取到的json反向操作cookie
			A.template('#template').renderReplace(json);
		}
		
		$('#bdbtn').on(A.options.clickEvent,function(){
			var card = $('#card').val();
			var pwd = $('#pwd').val();
			var market = $('#market').val();
			if(!card){
				A.alert('错误','卡号不能为空');
			}else if(!pwd){
				A.alert('错误','密码不能为空');
			}else if(!market || market=='0'){
				A.alert('错误','请选择市场');
			}else{
				var _url=encodeURIComponent("http://182.92.241.133:8001/API/FrontBackInf/BindCardToUser?UserID="+
						getCookie("UserID")+"&cardNo="+card+"&marketNo="+market+"&cardPwd="+$.md5(pwd)+"&deviceID=aabbccdd");
				myAjax(_url,gotoPage);//进行跨域请求json
			}
			return false;
		});
		
		function gotoPage(json){//供跨域请求获取到的json反向操作cookie
			A.alert('成功','卡号:'+$("#card").val()+'绑定成功<br>返回列表',function(){
			    A.Controller.html("card_list.html"); 
			});
		}
		</script>
	</body>
</html>